package com.sinopec.handdevice.api;

import com.sinopec.basemodule.AppConstants;
import com.sinopec.basemodule.http.HttpParam;
import com.sinopec.basemodule.http.api.AppService;
import com.sinopec.basemodule.http.api.HttpResult;
import com.sinopec.basemodule.http.api.RetroAPIFactory;
import com.sinopec.basemodule.model.app_model.SplashPicModel;
import com.sinopec.basemodule.model.app_model.WelcomeModel;
import com.sinopec.basemodule.model.login_model.ConfigInfo;
import com.sinopec.basemodule.model.MineInfoModel;

import java.util.HashMap;

import io.reactivex.Observable;
import okhttp3.ResponseBody;


public class AppApi {
    static {
        instance = new AppApi();
    }

    private static AppApi instance;
    private final AppService appService;

    public AppApi() {
        appService = RetroAPIFactory.create(AppService.class);
    }

    public static AppApi getInstance() {
        return instance;
    }

    /**
     * @author lwj
     * @Description: 获取基础配置接口
     */
    public Observable<HttpResult<ConfigInfo>> requestConfig() {
        HashMap<String, String> hashMap = HttpParam.createParams(true)
                .putParam(AppConstants.PARAM_PLATFORM, "2")
                .end();
        return appService.requestConfig(hashMap);
    }

    public Observable<ResponseBody> downloadFile(String path) {
        return appService.downloadFile(path);
    }

    public Observable<HttpResult<SplashPicModel>> requestSplashImg() {
        HashMap<String, String> hashMap = HttpParam.createParams(true)
                .putParam(AppConstants.PARAM_PLATFORM, "2")
                .end();
        return appService.requestSplashImg(hashMap);
    }

    /**
     * @author lwj
     * @Description: 查询app启动图
     * @date 2019/3/6 11:04
     */
    public Observable<HttpResult<WelcomeModel>> getStarTheFigure() {
        HashMap<String, String> hashMap = HttpParam.createParams(true)
                .putParam("token", "")
                .end();
        return appService.getStarTheFigure(hashMap);
    }

    public Observable<HttpResult<MineInfoModel>> getMineInfo() {
        HashMap<String, String> paramMap = HttpParam.createParams()
                .end();
        return appService.getMineInfo(paramMap);
    }
}
